/**
  ******************************************************************************
  * @file    stringget.c
  * @author  yan
  * @version 
  * @date    2016-12-21
  * @brief   
  ******************************************************************************
	*/

/*------------include----------------*/
#include <rtthread.h>
#include "stringget.h"
#include  "stdio.h"
#include  "ctype.h"
#include  "stdlib.h"
#include  "string.h"    


#define SPEEDARG  "speed" 
#define AXISARG  "axis"
#define PULSEARG  "pulse"

/**
  * @brief 
  * @param  
  * @retval 
  */
rt_uint8_t stringjudge(char ar[],char ar_flag[])
{

	if(strstr(ar,ar_flag)!=NULL)
	{
		memset(ar,1,strlen(ar_flag));
//		printf("STR_flag success\n");
		return 0;
	}
	else
	{
//		printf("STR_flag fail\n");
		return 1;
	}
}


/**
  * @brief 
  * @param  
  * @retval 
  */
int regular(char*substr,char*str)
{

	char *matching=strstr(str,substr);  
//	printf(matching);printf("\n");
	int length=strlen(substr);  
//	printf("%d\n",length);
	int value=atoi(matching+length); 
  
	return(value);
  

}
/**
  * @brief 
  * @param  
  * @retval 
  */
int getspeed(rt_uint8_t * str)
{
  return regular(SPEEDARG,(char *)str);
}
/**
  * @brief 
  * @param  
  * @retval 
  */
int getaxis(rt_uint8_t * str)
{
  return regular(AXISARG,(char *)str);
}

/**
  * @brief 
  * @param  
  * @retval 
  */
int getpulse(rt_uint8_t * str)
{
  return regular(PULSEARG,(char *)str);
}

#include <finsh.h>

rt_uint16_t  RegTest(int argc, char** argv)
{

//  int result;
//  char buf[] = "revcontinuous: speed:4000 axis:15";
  
  return isalnum('9');
  
}
FINSH_FUNCTION_EXPORT(RegTest,regextest);

